<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Dissasemble: src/fileLoader/fileLoader.c Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="Hopper_v3.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Dissasemble
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">This project receives as input a file.o and displays the assembly code for that object.</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('file_loader_8c.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">src/fileLoader/fileLoader.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="file_loader_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> ============================================================================</span>
<a name="l00003"></a>00003 <span class="comment"> Name        : fileLoader.c</span>
<a name="l00004"></a>00004 <span class="comment"> Author      :</span>
<a name="l00005"></a>00005 <span class="comment"> Version     :</span>
<a name="l00006"></a>00006 <span class="comment"> Copyright   : Your copyright notice</span>
<a name="l00007"></a>00007 <span class="comment"> Description : Load a binary input file</span>
<a name="l00008"></a>00008 <span class="comment"> ============================================================================</span>
<a name="l00009"></a>00009 <span class="comment"> */</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;<a class="code" href="file_loader_8h.html">fileLoader.h</a>&quot;</span>
<a name="l00012"></a>00012 
<a name="l00018"></a><a class="code" href="file_loader_8c.html#ad2caf348227d8c788423f66dc9bda3da">00018</a> <span class="keywordtype">char</span> <a class="code" href="file_loader_8c.html#ad2caf348227d8c788423f66dc9bda3da" title="Open a binary file to be read a dissasemble.">openBinaryFile</a>(<span class="keywordtype">char</span> * fileName, <span class="keywordtype">int</span> * <a class="code" href="my_obj_dump_8c.html#a6f8059414f0228f0256115e024eeed4b" title="Pointer to binary file.">fd</a>)
<a name="l00019"></a>00019 {
<a name="l00020"></a>00020         FILE *source;
<a name="l00021"></a>00021         <span class="keyword">struct </span>stat buf;
<a name="l00022"></a>00022         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> fileLen;
<a name="l00023"></a>00023 
<a name="l00024"></a>00024         <a class="code" href="debug_8h.html#a1b7e26bb727a722ca100ed856b4e1d98" title="Print Debug.">PRINT_DEBUG</a>(<a class="code" href="debug_8h.html#a41d588ee907c299c7a790964deeef02d" title="Debug all process.">DEBUG_ALL</a>, <span class="stringliteral">&quot;Opening %s ...\n&quot;</span>, fileName);
<a name="l00025"></a>00025 
<a name="l00026"></a>00026         <span class="keywordflow">if</span> (stat(fileName, &amp;buf) != 0)
<a name="l00027"></a>00027         {
<a name="l00028"></a>00028                 <a class="code" href="debug_8c.html#a8ded31085b483d44dbeb3adbecd2debf" title="Displays the error message.">PRINT_ERROR</a>(<span class="stringliteral">&quot;Unable to open the file: %s&quot;</span>, fileName);
<a name="l00029"></a>00029                 <span class="keywordflow">return</span> (<a class="code" href="debug_8h.html#ae4a97f0d170bc8dc771aac6c4f38ad1d" title="Response code when a process was run efficiently.">STATUS_ERROR</a>);
<a name="l00030"></a>00030         }
<a name="l00031"></a>00031 
<a name="l00032"></a>00032         source = fopen(fileName, <span class="stringliteral">&quot;rb&quot;</span>);
<a name="l00033"></a>00033         fseek(source, 0, SEEK_END);
<a name="l00034"></a>00034         fileLen = ftell(source);
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 
<a name="l00037"></a>00037         <a class="code" href="debug_8h.html#a1b7e26bb727a722ca100ed856b4e1d98" title="Print Debug.">PRINT_DEBUG</a>(<a class="code" href="debug_8h.html#a41d588ee907c299c7a790964deeef02d" title="Debug all process.">DEBUG_ALL</a>, <span class="stringliteral">&quot;%lu&quot;</span>, fileLen);
<a name="l00038"></a>00038 
<a name="l00039"></a>00039         <span class="keywordflow">if</span> (fileLen &gt;= <a class="code" href="config_8h.html#a6b20d41d6252e9871430c242cb1a56e7" title="Maximum file size input (100Mb)">BUFFER_SIZE</a>)
<a name="l00040"></a>00040         {
<a name="l00041"></a>00041                 printf(<span class="stringliteral">&quot;ERROR: Input file is bigger than 100mb.\n&quot;</span>);
<a name="l00042"></a>00042                 <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae4a97f0d170bc8dc771aac6c4f38ad1d" title="Response code when a process was run efficiently.">STATUS_ERROR</a>;
<a name="l00043"></a>00043         }
<a name="l00044"></a>00044         fclose(source);
<a name="l00045"></a>00045 
<a name="l00046"></a>00046         *fd = open(fileName, O_RDONLY);
<a name="l00047"></a>00047 
<a name="l00048"></a>00048         <span class="keywordflow">if</span> (*fd &lt; 0)
<a name="l00049"></a>00049         {
<a name="l00050"></a>00050                 <a class="code" href="debug_8c.html#a8ded31085b483d44dbeb3adbecd2debf" title="Displays the error message.">PRINT_ERROR</a>(<span class="stringliteral">&quot;Unable to open the file: %s&quot;</span>, fileName);
<a name="l00051"></a>00051                 <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae4a97f0d170bc8dc771aac6c4f38ad1d" title="Response code when a process was run efficiently.">STATUS_ERROR</a>;
<a name="l00052"></a>00052         }
<a name="l00053"></a>00053 
<a name="l00054"></a>00054         <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae56fdb340b23940f7a64ed2e37c1774a" title="Response code when a process has performed an error in its execution.">STATUS_SUCCESS</a>;
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 
<a name="l00061"></a><a class="code" href="file_loader_8h.html#afdbe4da59a22e4a4d61c5dda11eec604">00061</a> <span class="keywordtype">char</span> <a class="code" href="file_loader_8c.html#aa48471d9a6ab9dea2e3acc76367ecfd3" title="Close a binary file after work with it.">closeBinaryFile</a>(FILE *pFile)
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063         fclose(pFile);
<a name="l00064"></a>00064         <span class="keywordflow">return</span> <a class="code" href="debug_8h.html#ae56fdb340b23940f7a64ed2e37c1774a" title="Response code when a process has performed an error in its execution.">STATUS_SUCCESS</a>;
<a name="l00065"></a>00065 }
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="file_loader_8c.html">fileLoader.c</a>      </li>

    <li class="footer">Generated on Thu Oct 11 2012 12:28:10 for Dissasemble by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
